/**
 * 楼盘相关API
 */

import { http, Method } from "@/utils/request.js";

import api from "@/config/api.js";

/**
 * 获取列表
 * @returns {AxiosPromise}
 */
// export function findBuildingList(params) {
//   return http.request({
//     url: "/houseBuildings/searchByVO",
//     method: Method.GET,
//     needToken: true,
//     params,
//   });
// }
//统计--计算新售楼盘、在售楼盘、本月开盘楼盘、待售楼盘的数量 ==/sta
export function staBuilding() {
  return http.request({
    url: "/houseBuildings/sta",
    method: Method.GET,
    needToken: true
  });
}


//房源评价selectHouseEvals
export function selectBuildingEvals(params) {
  return http.request({
    url: "/api/houseApi/selectHouseEvals",
    method: Method.GET,
    needToken: true,
    params,
  });
}

//selectHouseHeart--收藏
export function selectBuildingHeart(params) {
  return http.request({
    url: "/api/houseApi/selectHouseHeart",
    method: Method.GET,
    needToken: true,
    params,
  });
}


// 插入楼房信息
// export function saveBuilding(params) {
//   return http.request({
//     url: "/houseBuildings",
//     method: Method.POST,
//     needToken: true,
//     data: params,
//   });
// }

export function saveBuilding(params) {
  return http.request({
    url: "/buildings",
    method: Method.POST,
    needToken: true,
    data: params,
  });
}

//更新楼盘
export function updateBuilding(params) {
  return http.request({
    url: "/buildings",
    method: Method.PUT,
    needToken: true,
    data: params,
  });
}

//楼盘通知addNotice
export function addNotice(params) {
  return http.request({
    url: "/buildings/addNotice",
    method: Method.POST,
    needToken: true,
    data: params,
  });
}

//getAllBuildings
export function getAllBuildings(params) {
  return http.request({
    url: "/buildings",
    method: Method.GET,
    needToken: true,
    params,
  });
}

export function getAdminBuildings(params) {
  return http.request({
    url: "/buildings/admin",
    method: Method.GET,
    needToken: true,
    params,
  });
}

// 根据 ID 获取楼盘
export function findBuildingById(id) {
  return http.request({
    url: "/buildings/" + id,
    method: Method.GET,
    needToken: true,
  });
}



/**
 *  @PutMapping(value = "/disable/{id}") 下架房源
 */
export function disableBuilding(id) {
  return http.request({
    url: "/buildings/disable/"+id,
    method: Method.PUT,
    needToken: true
  });
}

/**
 * @PutMapping(value = "/enable/{id}") 上架房源
 */
export function enableBuilding(id) {
  return http.request({
    url: "/buildings/enable/"+id,
    method: Method.PUT,
    needToken: true
  });
}



